#include "ThreadPool.hpp"
#include "Task.hpp"
#include "Log.hpp"
#include <iostream>
// #include<memory>

using namespace std;
using namespace log_ns;

int main()
{
    cout << GetCurrTime() << endl;

    // EnableScreen();//向显示器上打印日志
    EnableFile(); // 向文件里打印日志

    // unique_ptr<ThreadPool> tp=make_unique<ThreadPool>();//c++14

    // ThreadPool<Task> *tp=new ThreadPool<Task>();
    // tp->Init();
    // tp->Start();

    int cnt = 10;
    while (cnt)
    {
        // 不断地向线程池推送任务
        sleep(1);
        Task t(1, 1);
        ThreadPool<Task>::GetInstance()->Equeue(t);
        LOG(INFO, "equeue a task,%s\n", t.debug().c_str());
        cout << "cnt: " << cnt-- << endl;
    }

    ThreadPool<Task>::GetInstance()->Stop();
    LOG(INFO, "thread pool stop!\n");

    return 0;
}